{include file='public/header.html'}
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar" id="sidebar">
            {include file='public/sidebar.html'}
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" id="main">
            <h3 class="page-header">快速生成</h3>

            <div class="panel panel-default">
                <div class="panel-heading">一键生成</div>
                <div class="panel-body">

                    <form class="form-inline submit-ajax" action="{:url('action')}" method="post">
                        <div class="form-group">
                            <label for="sign">标识：</label>
                            <input type="text" id="sign" name="sign" value="blog" class="form-control" placeholder="输入标识(表名)"/>
                        </div>
                        <div class="form-group">
                            <label for="cmd">操作：</label>
                            <select name="cmd" id="cmd" class="form-control">
                                <option value="make_table">生成表</option>
                                <option value="remove_table">移除表</option>
                                <option value="make_mvc">生成MVC</option>
                                <option value="remove_mvc">移除MVC</option>
                            </select>
                        </div>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </form>

                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">快速生成<span class="pull-right"><a href="javascript:history.back(-1);">返回</a></span></div>
                <div class="panel-body">
                    <p>开发流程：设计数据表 —> 生成表 —> 生成MVC —> 添加菜单 —> 完善模板 —> 完善模型 —> 完善控制器</p>
                    <p class="text-danger">可通过命令行或以下按钮生成: 表，模型，控制器，视图模板 来实现CRUD。</p>
                </div>

            </div>

            <div class="panel panel-default">
                <div class="panel-heading">设计数据表</div>
                <div class="panel-body">
                    <p>创建表结构模板,如：<code>app/admin/command/make/table/blog.tpl</code></p>
                    <pre>
CREATE TABLE `aphp_blog` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `title` varchar(100) NOT NULL DEFAULT '' COMMENT '标题',
  `content` text NOT NULL COMMENT '内容',
  `sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
  `update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='文章表';</pre>
                    <p>表结构必须包含字段：<code>id,title,status</code>，便于生成<code>MVC</code></p>
                    <p>生成模板位于：<code>app/admin/command/make</code>，可修改控制器，模型，视图的生成模板。</p>
                </div>

            </div>


            <div class="panel panel-default">
                <div class="panel-heading">生成文件</div>
                <div class="panel-body">
                    <ul>
                        <li>数据模型：<code>app/admin/model/Blog.php</code></li>
                        <li>控制器：<code>app/admin/controller/Blog.php</code></li>
                        <li>列表模板：<code>app/admin/view/blog/index.html</code></li>
                        <li>新增模板：<code>app/admin/view/blog/add.html</code></li>
                        <li>编辑模板：<code>app/admin/view/blog/edit.html</code></li>
                    </ul>
                </div>

            </div>

            <div class="panel panel-default">
                <div class="panel-heading">添加菜单</div>
                <div class="panel-body">
                    <p>在 <code>app/admin/view/public/sidebar.html</code> 中添加：</p>
<pre>
&lt;li{#:nav_active('blog')#}&gt;&lt;a href="{#:url('blog/index')#}"&gt;&lt;i class="glyphicon glyphicon-tag"&gt;&lt;/i&gt; 文章管理&lt;/a&gt;&lt;/li&gt;
</pre>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">完善模板</div>
                <div class="panel-body">
                    <p>列表模板：</p>
                    <p>表头 <code>&lt;th&gt;排序&lt;/th&gt; &lt;th&gt;更新时间&lt;/th&gt;</code> 表体 <code>&lt;td&gt;{#$vo.sort#}&lt;/td&gt; &lt;td&gt;{#$vo.update_time|get_time_ago#}&lt;/td&gt;</code></p>
                    <p>编辑模板：</p>
                    <pre>&lt;div class=&quot;form-group&quot;&gt;
    &lt;label for=&quot;content&quot; class=&quot;col-sm-1 control-label&quot;&gt;*内容&lt;/label&gt;
    &lt;div class=&quot;col-sm-11&quot;&gt;
        &lt;textarea name=&quot;content&quot; id=&quot;content&quot; rows=&quot;2&quot; class=&quot;form-control&quot; placeholder=&quot;请输入内容&quot;&gt;{#$vo.content#}&lt;/textarea&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;form-group&quot;&gt;
    &lt;label for=&quot;sort&quot; class=&quot;col-sm-1 control-label&quot;&gt;*排序&lt;/label&gt;
    &lt;div class=&quot;col-sm-11&quot;&gt;
        &lt;input type=&quot;text&quot; id=&quot;sort&quot; name=&quot;sort&quot; class=&quot;form-control&quot; style=&quot;width:auto;&quot; placeholder=&quot;请输入排序值&quot; value=&quot;{#$vo.sort#}&quot; /&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre>
                    <p>新增模板：代码同上，去除<code>{#$vo.content#}</code>和<code>{#$vo.sort#}</code></p>

                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">完善模型</div>
                <div class="panel-body">
                    <p>在 <code>app/admin/model/Blog.php</code> 中添加验证规则：</p>
                    <pre>['content', 'required', '内容必须', IF_MUST, AC_BOTH],
['sort', 'number', '排序必须是数字', IF_MUST, AC_BOTH],
</pre>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">完善控制器</div>
                <div class="panel-body">
                    <p>在 <code>app/admin/controller/Blog.php</code> 中设置列表排序：</p>
                    <pre>protected string $order = 'sort ASC,id DESC';</pre>
                </div>
            </div>

        </div>
    </div>
</div>
{include file='public/footer.html'}
</body>
</html>